<script setup>
const props = defineProps({
    items: {
        type: Array,
        default: () => []
    }
})
</script>

<template>
    <div class="main">
        <section class="list-item" v-for="item in items" :key="item.title">
            <div class="item-image">
                <img :src="item.image" :alt="item.title" />
            </div>
            <div class="item-text">
                <div class="text-title">{{ item.title }}</div>
                <div class="text-desc">{{ item.desc }}</div>
            </div>
        </section>
    </div>
</template>

<style lang="scss" scoped>
.main {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: auto;
    /* 改为自动高度 */
    min-height: 100vh;
    perspective: 1px;
    transform-style: preserve-3d;
    /* 关键：提示浏览器优化 */
    will-change: transform;
}

.list-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 45vh;
    /* 每个section占满一屏 */
    overflow: hidden;
    /* 关键：提示浏览器优化 */
    will-change: transform;

    .item-image {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        transform: translateZ(-1px) scale(2);
        /* 关键：提示浏览器优化 */
        will-change: transform;

        &::after {
            content: "";
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.4);
            transition: all 0.3s ease;
            z-index: 1;
        }
    }

    .item-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        /* 关键：图片也需要优化提示 */
        will-change: transform;
    }

    .item-text {
        color: #ffffff;
        font-family: "Courier New", Courier, monospace;
        text-align: center;
        transform: translateZ(0);
        z-index: 2;
        position: relative;
    }
}
</style>